import java.util.Scanner;

public class TestLinearEquation {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        System.out.println("=== 测试 9.11 线性方程组 ===");
        System.out.println("示例: 1 2 3 4 5 6 应该输出 x=-4.00, y=4.50");
        System.out.print("请输入 a b c d e f (用空格分隔): ");
        
        double a = input.nextDouble();
        double b = input.nextDouble();
        double c = input.nextDouble();
        double d = input.nextDouble();
        double e = input.nextDouble();
        double f = input.nextDouble();

        // 直接创建对象
        LinearEquation equation = new LinearEquation(a, b, c, d, e, f);

        if (equation.isSolvable()) {
            System.out.printf("解: x = %.2f, y = %.2f\n", equation.getX(), equation.getY());
        } else {
            System.out.println("方程无解。");
        }
        
        input.close();
    }
}

class LinearEquation {
    private double a, b, c, d, e, f;
    
    public LinearEquation(double a, double b, double c, double d, double e, double f) {
        this.a = a; this.b = b; this.c = c;
        this.d = d; this.e = e; this.f = f;
    }
    
    public boolean isSolvable() {
        return (a * d - b * c) != 0;
    }
    
    public double getX() {
        return (e * d - b * f) / (a * d - b * c);
    }
    
    public double getY() {
        return (a * f - e * c) / (a * d - b * c);
    }
}